define(function (require, exports, module) {
    /*require.async("jquery",function () {
        require.async("jqueryValidate",function () {
            $(function () {
                $.validator.addMethod("isPhone", function (value, element) {
                    var isPhone = /^1[3|4|5|7|8]\d{9}$/;
                    return this.optional(element) || (isPhone.test(value));
                }, "请输入正确的格式");

                /!*登录校验*!/
                $("#forgotForm").validate({
                    rules: {
                        iphoneUser: {
                            required: true,
                            isPhone:true
                        },
                        iphonePassWord: {
                            required: true
                            /!*rangelength:[5,20],
                             isPassWord:true*!/
                        }
                    },
                    messages: {
                        iphoneUser: {
                            required: "请输入用户名",
                            isPhone:"手机号码格式错误"
                        },
                        iphonePassWord: {
                            required: "请输入密码"
                        }
                    },

                    errorPlacement: function(error, element) {
                        var tNum=$("#errorzyc").children().length;
                         setTimeout(function () {
                             $("#errorzyc").html("");
                         },1500);

                        if(tNum>0){
                            $("#errorzyc").html("");
                        }
                        error.appendTo($("#errorzyc"));


                    },

                });
                /!*登录校验*!/
            })
        });
    })*/

    var $=require("jquery");
    var isPhone = /^1[3|4|5|7|8]\d{9}$/;
    var timeOut;
    /*弹出框消失*/
     function errorHide() {
         clearTimeout(timeOut);
         timeOut=setTimeout(function () {
              $("#errorzyc").html("");
            $("#errorzyc").css({"display":"none"})
          },2000)
     }
    /*弹出框消失*/
     /*错误提示*/
      function errorShow(message,self) {
          $("#errorzyc").html(message);
          $("#errorzyc").css({"display":"block"});
          $(self).attr("isTure","false");
          errorHide();
      }
     /*错误提示*/
     /*异步验证*/
    function ajaxVerification(url,val) {
        $.ajax({

            url:url,
            type:'POST', //GET
            data:{
                phone:val
            },
            timeout:5000,    //超时时间
            success:function(data,textStatus,jqXHR){
                if(data!="true"){
                    errorShow("手机号码未注册");
                }
            },
            error:function(xhr,textStatus){

            },
            complete:function (XMLHttpRequest,status) {
                if(status=="timeout"){
                    console.log("请求超时");
                }

            }
        })
    }
     /*异步验证*/


     /*手机号验证*/
    $("#iphoneUser").on("blur",function () {
        if($(this).val()==""){
            errorShow("请输入手机号",this);
        }else{
            if(!(isPhone.test($(this).val()))){
                errorShow("手机号格式错误");
            }else{
              ajaxVerification("http://localhost:82/php/index.php",$(this).val());
                $(this).attr("isTure","false");
            }
        }
        $(this).attr("isTure","true");

        console.log($(this).attr("isTure"));
    });

    /*手机号验证*/
    /*验证码验证*/
    $("#iphonePassWord").on("blur",function () {
        if($(this).val()==""){
            errorShow("请输入验证码");
        }else{
            ajaxVerification("http://localhost:82/php/verificationCode.php",$(this).val());
        }
    });
    /*验证码验证*/

});

